package algo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import solver.SolverIface;
import sudoku.SudokuEinzelfeld;
import sudoku.SudokuSpielfeld;

public class ConvertStructToArray implements SolverIface {

	int[] completeArray = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
	private List<Integer> completeList = new ArrayList<Integer>();
	private SudokuSpielfeld sf;

	public ConvertStructToArray(SudokuSpielfeld sf) {
		this.sf = sf;

		/* init list */
		for (int i = 0; i < completeArray.length; i++) {
			completeList.add(completeArray[i]);
		}
	}

	public Set<Integer> returnPossibleNumbersWithLookUpToOtherStructs(
			SudokuEinzelfeld ef) {
		int blockNr = ef.getBlockNr();
		int spalte = ef.getCol();
		int zeile = ef.getRow();

		List<Integer> block = sf.returnblockInts(blockNr);
		List<Integer> zeileList = sf.returnzeileInts(zeile);
		List<Integer> spalteList = sf.returnspalteInts(spalte);

		Compress compressor = new Compress();

		return compressor.compressLists(block, spalteList, zeileList);

	}

	public Set<Integer> returnPossibleNumbersWithReduction() {
		Map<Integer, Set<SudokuEinzelfeld>> possibleSets = new HashMap<Integer, Set<SudokuEinzelfeld>>(); 
		for (int row = 0; row < 9; row++) {
			for (int col = 0; col < 9; col++) {
				SudokuEinzelfeld ef = sf.getSudokuFeld()[row][col];
				if(!ef.isTouchedRow()){
					List<SudokuEinzelfeld> sfRow = sf.returnRow(ef.getRow());
					for (int i = 1; i <= 9; i++) {
						
					}
				}
			}
		}
		return null;

	}

	public List<SudokuEinzelfeld> reduceWithLookUpToOtherFields(
			SudokuEinzelfeld ef) {
		List<SudokuEinzelfeld> sfSet = sf.returnblock(ef.getBlockNr());
		for (SudokuEinzelfeld sudokuEinzelfeld : sfSet) {
			if (sudokuEinzelfeld.equals(ef)) {

			} else {

			}
		}
		return sfSet;

	}

	public List<Integer> convertFeldToInt(List<SudokuEinzelfeld> efList) {
		List<Integer> numbers = new LinkedList<Integer>();
		for (SudokuEinzelfeld sudokuEinzelfeld : efList) {
			numbers.remove(sudokuEinzelfeld.getNumber());
		}
		return numbers;
	}

}
